package alex.cicy;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Properties;

public abstract class Env {
    private static Logger logger = LoggerFactory.getLogger(Env.class);
    private static String env = PropertiesHelper.getProp("env");
    private static String version;
    public static final String innerIP = "192.168";
    public static final String outerIP = "10.1";
    static {
        if (!isDev()) {
            try {
                Properties props = new Properties();
                props.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("version.properties"));
                version = props.getProperty("version");
            } catch (Exception e) {
                logger.error("", e);
            }
        }
    }

	/**
	 * @return true 外网生产环境
	 */
	public static boolean isProd() {
		//默认是生产环境，以免外网出错
		return env == null || "prod".equals(env);
	}
	
	/**
	 * @return true 开发人员自己的环境
	 */
	public static boolean isDev() {
		return "dev".equals(env);
	}
	
	/**
	 * @return true 内网服务器环境
	 */
	public static boolean isStage() {
		return "stage".equals(env);
	}

    public static String getVersion() {
        return version;
    }
}
